package com.cx.base.day13_io.io_autoTest;

/**
 * @Author: robert.song
 * @Date: Created in 2021/11/25
 */
public class JudgeCharEncode {
    public static void main(String[] args) {
        System.out.println(stringToUnicode("宋亚辉"));
        ;
    }

    public static String stringToUnicode(String s) {
        String str = "";
        for (int i = 0; i < s.length(); i++) {
            int ch = (int) s.charAt(i);
            if (ch > 255)
                str += s.charAt(i) + ": " + "\\u" + Integer.toHexString(ch)
                        + "\n";
            else
                str += s.charAt(i) + ": " + "\\u00" + Integer.toHexString(ch)
                        + "\n";
        }
        return str;
    }
}
